package com.jiazhong.basic.shuxin.thread;

public class DemoD4 {

    private ThreadLocal<Integer> threadLocal = ThreadLocal.withInitial(() -> 0);

    public void changeNumber() {
        String currentThreadName = Thread.currentThread().getName();
        System.out.println(currentThreadName + "开始对变量进行自增操作，目前值：" + threadLocal.get());
        threadLocal.set(threadLocal.get() + 1);
        System.out.println(currentThreadName + "结束了对变量的自增操作，目前值：" + threadLocal.get());
    }
}
